home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_nn-tk.idb / usr / freeware / lib / nn / tcl / main.tcl.z / main.tcl
Encoding:
Text File  |  1999-04-16  |  38.6 KB  |  1,354 lines

  1. #
  2. #    Upper Buttons
  3. #
  4. proc make_group_menu  {} {
  5.     msg_Make "Making group cascading menus" 0
  6.     update
  7.     grp_menu
  8.     .top.m.menu delete 1
  9.     msg_destroy
  10. }
  11.  
  12. proc mksedit {} {
  13.     Sedit_Pref
  14. #    exmh_bind_e
  15.     wm minsize .seditpref 0 0
  16. #   Sedit_Pref clears entry Class bindings
  17.     bind .seditpref <Unmap> {after 1000 setup_bindings}
  18. }
  19.  
  20. proc mksedit_compose {} {
  21.     Sedit_ComposeUI
  22.     wm minsize .compose 0 0
  23. }
  24.  
  25. proc menu_sedit {} {
  26.     Preferences_Dialog
  27.     .pref.but.save configure -command nn_PreferencesSave
  28. }
  29.  
  30. proc do_uri {} {
  31.     global has_exmh
  32.     
  33.     if {$has_exmh == 1} {
  34.     if {[catch {Uri_ScanMsg .more.t}] != 0} {
  35.         URI_ScanMsg .more.t
  36.     }
  37.     }
  38. }
  39.  
  40. proc top_buttons {} {
  41.     global token Config has_exmh nn_x_dir
  42.  
  43.     frame .top 
  44.     frame .top.x -borderwidth 2  -relief ridge
  45.     
  46.     if {[winfo screendepth .] > 8} {
  47.     image create photo nn -file $nn_x_dir/tcl/nn.ppm
  48.     } else {
  49.     image create bitmap nn -file $nn_x_dir/tcl/nn.xbm
  50.     }
  51.     button .top.pic -image nn -borderwidth 1  \
  52.     -relief sunken  -highlightthickness 0 -padx 3 -pady 4
  53.  
  54.     menubutton .top.m -text "Groups" -menu .top.m.menu -bd 1 \
  55.     -relief raised  -pady 3 -indicatoron 1
  56.     menu .top.m.menu
  57.     if {!$Config(mk_group_menu)} {
  58.     .top.m.menu add command -label "Setup Groups menu" \
  59.         -command "make_group_menu"
  60.     }
  61.     
  62.     menubutton .top.a -text "article" -menu .top.a.art -bd 1 \
  63.     -relief raised  -pady 3 -indicatoron 1
  64.     menu .top.a.art
  65.     .top.a.art add command -label "Post news" \
  66.         -command "put_extended {post}"
  67.     .top.a.art  add command -label "Followup news" \
  68.     -command "put_extended {follow}"
  69.     .top.a.art add separator
  70.     .top.a.art  add command -label "Mail article" \
  71.     -command "put_extended {mail}"
  72.     .top.a.art  add command -label "Mail reply" \
  73.     -command "put_extended {reply}"
  74.     .top.a.art add separator
  75.     .top.a.art add cascade -label "Process articles" -menu .top.a.art.a
  76.     menu .top.a.art.a 
  77.     .top.a.art.a  add command -label "Turn URLs into Buttons" \
  78.     -command do_uri
  79.     .top.a.art.a  add command -label "Treat selection as URL" \
  80.     -command URI_OpenSelection
  81.     .top.a.art.a  add command -label "View using PGP" \
  82.     -command "put_extended {pgp}"
  83.     .top.a.art.a add separator
  84.     .top.a.art.a  add command -label "decode" \
  85.     -command "put_extended {decode}"
  86.     .top.a.art.a  add command -label "deview" \
  87.     -command "put_extended {deview}"
  88.     .top.a.art.a  add command -label "patch" \
  89.     -command "put_extended {patch}"
  90.     .top.a.art.a  add command -label "print" \
  91.     -command "put_extended {print}"
  92.     .top.a.art.a  add command -label "unshar" \
  93.     -command "put_extended {unshar}"
  94.      .top.a.art add cascade -label "Save articles" -menu .top.a.art.s
  95.     menu .top.a.art.s
  96.     .top.a.art.s  add command -label "save-body" \
  97.     -command "put_extended {save-body}"
  98.     .top.a.art.s  add command -label "save-short" \
  99.     -command "put_extended {save-short}"
  100.     .top.a.art.s  add command -label "save-full" \
  101.     -command "put_extended {save-full}"
  102.     .top.a.art add cascade -label "misc" \
  103.     -menu .top.a.art.m
  104.     menu .top.a.art.m
  105.     .top.a.art.m add command -label "full headers" \
  106.     -command "put_extended {page=0}"
  107.     .top.a.art.m add separator
  108.     .top.a.art.m add command -label "leave-next" \
  109.     -command "put_extended {leave-next}"
  110.     .top.a.art.m add command -label "leave-article" \
  111.     -command "put_extended {leave-article}"
  112.     .top.a.art.m add separator
  113.     .top.a.art.m add command -label "rot13" \
  114.     -command "put_extended {rot13}"
  115.     .top.a.art.m add command -label "compress" \
  116.     -command "put_extended {compress}"
  117.     .top.a.art.m add command -label "full-digest" \
  118.     -command "put_extended {full-digest}"
  119.     
  120.     menubutton .top.f -text "functs" -menu .top.f.func -bd 1 \
  121.     -relief raised  -pady 3 -indicatoron 1
  122.     menu .top.f.func
  123.     .top.f.func add command -label "reload groups" \
  124.     -command "put_extended {reload} m"
  125.     .top.f.func add cascade -label "make window" -menu .top.f.func.w
  126.     menu .top.f.func.w
  127.     .top.f.func.w add command -label "group list" \
  128.     -command "list_Make .groups grp_list"
  129.     .top.f.func.w add command -label "folder list" \
  130.     -command "list_Make .folders folder_list"
  131.  
  132.     .top.f.func add cascade -label "Kill and Select" \
  133.     -menu .top.f.func.ks
  134.     menu .top.f.func.ks
  135.     .top.f.func.ks add command -label "Edit" \
  136.     -command "killsel_setup"
  137.     .top.f.func.ks add separator
  138.     setup_menu .top.f.func.ks 
  139.  
  140.     .top.f.func add command -label "cancel articles" \
  141.     -command "put_extended {cancel}"
  142.     .top.f.func add command -label "(un)subscribe group" \
  143.     -command "put_extended {unsub}"
  144.     .top.f.func add separator
  145.     .top.f.func add command -label "previous message" \
  146.     -command "put_funct $token(K_LAST_MESSAGE)"
  147.     
  148.     menubutton .top.o -text "menu" -menu .top.o.others -bd 1 \
  149.     -relief raised  -pady 3 -indicatoron 1
  150.     menu .top.o.others
  151.     .top.o.others add command -label "read mail" \
  152.     -command "put_extended {rmail}"
  153.     .top.o.others add cascade -label "sort type" -menu .top.o.others.s
  154.     menu .top.o.others.s
  155.     .top.o.others.s add command -label "Sort: arrival" \
  156.     -command "put_extended {sort arrival}"
  157.     .top.o.others.s add command -label "Sort: subject" \
  158.     -command "put_extended {sort subject}"
  159.     .top.o.others.s add command -label "Sort: lexical" \
  160.     -command "put_extended {sort lexical}"
  161.     .top.o.others.s add command -label "Sort: age" \
  162.     -command "put_extended {sort age}"
  163.     .top.o.others.s add command -label "Sort: sender" \
  164.     -command "put_extended {sort sender}"
  165.     .top.o.others.s add command -label "Sort: thread lexical" \
  166.     -command "put_extended {sort thread-lexical}"
  167.     .top.o.others.s add command -label "Sort: thread age" \
  168.     -command "put_extended {sort thread-date}"
  169.     .top.o.others add cascade -label "consolidate menu" \
  170.     -menu .top.o.others.c
  171.     menu .top.o.others.c
  172.     .top.o.others.c add command -label "Menu: consolidate" \
  173.     -command "put_extended {set consolidated-menu on}"
  174.     .top.o.others.c add command -label "Menu: unconsolidate" \
  175.     -command "put_extended {set consolidated-menu off}"
  176.     .top.o.others add cascade -label "menu mode" -menu .top.o.others.m
  177.     menu .top.o.others.m
  178.     .top.o.others.m add command -label "select regexp" \
  179.     -command "put_extended {find}"
  180.     .top.o.others.m add command -label "select-auto" \
  181.     -command "put_extended {select-auto}"
  182.     .top.o.others.m add command -label "select-invert" \
  183.     -command "put_extended {select-invert}"
  184.     .top.o.others.m add command -label "select-range" \
  185.     -command "put_extended {select-range}"
  186.     .top.o.others.m add command -label "unselect-all" \
  187.     -command "put_extended {unselect-all}"
  188.     .top.o.others.m add separator
  189.     .top.o.others.m add command -label "first page" \
  190.     -command "put_extended {page=1}"
  191.     .top.o.others.m add command -label "last page" \
  192.     -command "put_extended {page=$}"
  193.     .top.o.others.m add separator
  194.     .top.o.others.m add command -label "open-subject" \
  195.     -command "put_extended {open-subject}"
  196.     .top.o.others.m add command -label "close-subject" \
  197.     -command "put_extended {close-subject}"
  198.     .top.o.others.m add separator
  199.     .top.o.others.m add command -label "continue-no-mark" \
  200.     -command "put_extended {continue-no-mark}"
  201.     .top.o.others.m add command -label "read-return" \
  202.     -command "put_extended {read-return}"
  203.     .top.o.others.m add command -label "unread" \
  204.     -command "put_extended {unread}"
  205.  
  206.  
  207.     
  208.     menubutton .top.help -text "Info"  -menu .top.help.m -bd 1 \
  209.     -relief raised  -pady 3 -indicatoron 1
  210.     menu .top.help.m
  211.     .top.help.m add cascade -label "nn-tk Help" -menu .top.help.m.n
  212.     menu .top.help.m.n
  213.     .top.help.m.n add command -label "description" \
  214.     -command "put_extended {help nn-tk}"
  215.     .top.help.m.n add command -label "main window" \
  216.     -command "put_extended {help nn-tk-main}"
  217.     .top.help.m.n add command -label "group list" \
  218.     -command "put_extended {help nn-tk-groups}"
  219.     .top.help.m.n add command -label "modify panel" \
  220.     -command "put_extended {help nn-tk-modify}"
  221.     .top.help.m.n add command -label "TK-bindings" \
  222.     -command "put_extended {help tk-bindings}"
  223.     .top.help.m.n add command -label "options" \
  224.     -command "put_extended {help options}"
  225.     .top.help.m add cascade -label "nn Help" -menu .top.help.m.h
  226.     menu .top.help.m.h
  227.     .top.help.m.h add command -label "Help" -command "put_extended {help}"
  228.     .top.help.m.h add command -label "attr" \
  229.     -command "put_extended {help attr}"
  230.     .top.help.m.h add command -label "commands" \
  231.     -command "put_extended {help commands}"
  232.     .top.help.m.h add command -label "extended" \
  233.     -command "put_extended {help extended}"
  234.     .top.help.m.h add command -label "map" -command "put_extended {help map}"
  235.     .top.help.m.h add command -label "menu mode" \
  236.     -command "put_extended {help menu}"
  237.     .top.help.m.h add command -label "more mode" \
  238.     -command "put_extended {help more}"
  239.     .top.help.m.h add command -label "set variable" -command "put_extended {help set}"
  240.     .top.help.m.h add command -label "show variable" \
  241.     -command "put_extended {help show}"
  242.     .top.help.m.h add command -label "sort" \
  243.     -command "put_extended {help sort}"
  244.     .top.help.m.h add command -label "variables" \
  245.     -command "put_extended {help variables}"
  246.     .top.help.m.h add command -label "nntp" \
  247.     -command "put_extended {help nntp}"
  248.     .top.help.m add separator
  249.     .top.help.m add cascade -label "show info" -menu .top.help.m.sh
  250.     menu .top.help.m.sh
  251.     .top.help.m.sh add command -label "set" \
  252.     -command "put_extended {set}"
  253.     .top.help.m.sh add command -label "set all" \
  254.     -command "put_extended {set all}"
  255.     .top.help.m.sh add separator
  256.     .top.help.m.sh add command -label "kill" \
  257.     -command "put_extended {show kill}"
  258.     .top.help.m.sh add separator
  259.     .top.help.m.sh add command -label "groups" \
  260.     -command "put_extended {show groups}"
  261.     .top.help.m.sh add command -label "groups all" \
  262.     -command "put_extended {show groups all}"
  263.     .top.help.m.sh add command -label "groups subscr" \
  264.     -command "put_extended {show groups subscr}"
  265.     .top.help.m.sh add command -label "groups total" \
  266.     -command "put_extended {show groups total}"
  267.     .top.help.m.sh add command -label "groups unsub" \
  268.     -command "put_extended {show groups unsub}"
  269.     .top.help.m.sh add separator
  270.     .top.help.m.sh add command -label "map" \
  271.     -command "put_extended {show map}"
  272.     .top.help.m.sh add command -label "map key" \
  273.     -command "put_extended {show map key}"
  274.     .top.help.m.sh add command -label "map menu" \
  275.     -command "put_extended {show map menu}"
  276.     .top.help.m.sh add command -label "map show" \
  277.     -command "put_extended {show map show}"
  278.     .top.help.m.sh add command -label "map #" \
  279.     -command "put_extended {show map #}"
  280.     .top.help.m.sh add separator
  281.     .top.help.m.sh add command -label "rc" \
  282.     -command "put_extended {show rc}"
  283.     if {[info procs Sedit_ComposeUI] != ""} {
  284.     .top.help.m add command -label "Compose key sequences" \
  285.         -command "mksedit_compose"
  286.     } else {
  287.     .top.help.m add command -label "Edit Character compose" \
  288.         -command "mksedit_compose" -state disabled
  289.     }
  290.     .top.help.m add separator
  291.     .top.help.m add command -label "Man" -command "put_extended {man}"
  292.     
  293.     menubutton .top.macro -text "USER"  -menu .top.macro.m -bd 1 \
  294.     -relief raised  -pady 3 -indicatoron 1
  295.     menu .top.macro.m
  296.     user_menu .top.macro.m
  297.     
  298.     menubutton .top.option -text "Setup" -menu .top.option.m -bd 1 \
  299.     -relief raised  -pady 3 -indicatoron 1
  300.     menu .top.option.m
  301.     .top.option.m add command -label "Save Window geometry" \
  302.     -command "config_save_geom"
  303.     .top.option.m add separator
  304.     if { $has_exmh} {
  305.     .top.option.m add command -label "Key bindings" \
  306.         -command "mksedit"
  307.     .top.option.m add command -label "Exmh options" \
  308.         -command "menu_sedit"
  309.     } else {
  310.     .top.option.m add command -label "Key bindings" \
  311.         -command "mksedit" -state disabled
  312.     .top.option.m add command -label "Exmh options" \
  313.         -command "Preferences_Dialog" -state disabled
  314.     }    
  315.     .top.option.m add separator
  316.     .top.option.m add command -label "NN-TK General" -command {opt_Make vars_misc options options_fill $vars_misc "NN-TK general options"}
  317.     .top.option.m add command -label "NN-TK Group List" -command {opt_Make vars_group options options_fill $vars_group "NN-TK group list options"}
  318.     .top.option.m add command -label "NN-TK Group Cascade Menu" -command {opt_Make vars_cascade options options_fill $vars_cascade "NN-TK group menu options"}
  319.     .top.option.m add command -label "NN-TK Balloon help" -command {opt_Make vars_balloon options options_fill $vars_balloon "NN-TK Balloon help options"}
  320.     .top.option.m add separator
  321.  
  322.     .top.option.m add cascade -label "NN Variables" -menu .top.option.m.v
  323.     menu .top.option.m.v
  324.  
  325.     set label [option get .top.option labels {} ]
  326.     set i 0
  327.     foreach m [option get .top.option entrylist {} ] {
  328.     .top.option.m.v add command -label [lindex $label $i] \
  329.         -command "variables_Make $m \"[lindex $label $i]\""
  330.     incr i
  331.     }
  332.     .top.option.m.v add separator
  333.     .top.option.m.v add command -label "(modified)" \
  334.     -command "variables_Make m modified"
  335.     .top.option.m.v add command -label "(all)" \
  336.     -command "variables_Make a all"
  337.     .top.option.m add separator
  338.  
  339.     global userc_v
  340.     set userc_v(0) "User defined menu entries"
  341.     set userc_v(1) "Command"
  342.     set userc_v(2) "Description"
  343.     .top.option.m add command -label "USER Command Menu" \
  344.     -command "table_Make user userc_v .top.macro.m com_user des_user"
  345.     .top.option.m add separator
  346.  
  347.     global color_v
  348.     set color_v(0) "Color Group List"
  349.     set color_v(1) "Match string"
  350.     set color_v(2) "Color"
  351.     .top.option.m add command -label "Color Group List" \
  352.     -command "table_Make color color_v .groups.list col_pattern col_name"
  353.  
  354.     button .top.qu -text "quit"  -command "put_funct \{$token(K_QUIT)\} m" \
  355.     -width 8 -padx 0 -pady 2
  356.  
  357.  
  358.     pack  .top.m  .top.option   .top.a .top.o .top.f .top.macro \
  359.     .top.help   -side left -padx 3 -pady 2 \
  360.     -in .top.x -side left
  361.     pack .top.pic -side left -anchor w
  362.  
  363.     button .top.hlp  -text "Help" -command "put_extended {help nn-tk-main}"
  364.     pack .top.hlp -side right
  365.  
  366.     pack .top.qu -padx 12 -side right
  367.  
  368.     set color_bg [.top cget -background]
  369.     button .top.cancel -text "C" -command "nntp_abort" \
  370.     -disabledforeground $color_bg -state disabled \
  371.     -borderwidth 0 -cursor left_ptr
  372.     pack .top.cancel -side right
  373.  
  374.     pack .top.x  -side left -padx 8
  375. }
  376.  
  377. proc nntp_active_cursor {} {
  378.     . configure -cursor watch
  379.     .more.t configure -cursor watch
  380.     .menu.article configure -cursor watch
  381.     .groups.list configure -cursor watch
  382. }
  383.  
  384. proc nntp_active {} {
  385.     .top.cancel configure -background red -foreground white -state normal \
  386.     -borderwidth 3
  387.     nntp_active_cursor
  388.     if {[prefetching] == "1"} {
  389.     mprompt_msg "Waiting for prefetcher"
  390.     } 
  391.     update
  392. }
  393.  
  394. proc nntp_inactive {} {
  395.     
  396.     after cancel nntp_active
  397.  
  398.     if {[.top.cancel cget -state] != "disabled"} {
  399.     set color_bg [.top cget -background ]
  400.  
  401.     .top.cancel configure -background $color_bg -foreground $color_bg\
  402.         -state disabled -borderwidth 0
  403.     }
  404.     . configure -cursor left_ptr
  405.     .more.t configure -cursor left_ptr
  406.     .menu.article configure -cursor left_ptr
  407.     .groups.list configure -cursor left_ptr
  408. }
  409.  
  410. proc nntp_started {} {
  411.     global Config
  412.  
  413.     if {$Config(cprompt_delay) == 0} {
  414.     nntp_active
  415.     } else {
  416.     after [expr $Config(cprompt_delay)*1000] nntp_active
  417.     }
  418. }
  419.  
  420. proc middle_buttons {} {
  421.     global token
  422.  
  423.     if {[winfo exists .middle]} {
  424.     destroy .middle
  425.     }
  426.     frame .middle -borderwidth 2  -relief ridge
  427.     button .middle.pg -text "prev G"  \
  428.     -command "put_funct $token(K_PREVIOUS) m" -width 8 -padx 0 -pady 2    
  429.     button .middle.ps -text " < "  \
  430.     -command "put_funct $token(K_PREV_PAGE) m" -width 3 -padx 0 -pady 2
  431.     button .middle.bmenu -text "="  \
  432.     -command "put_funct $token(K_BACK_TO_MENU)" -width 3 -padx 0 -pady 2
  433.     button .middle.ns -text " > "  \
  434.     -command "put_funct $token(K_NEXT_PAGE) m" -width 3 -padx 0 -pady 2
  435.     button .middle.nread -text "read/skip"  \
  436.     -command "put_funct $token(K_READ_GROUP_UPDATE)" -width 10 -padx 0 -pady 2
  437.     button .middle.ng -text "next G"  \
  438.     -command "put_funct $token(K_NEXT_GROUP_NO_UPDATE) m" -width 8 -padx 0 -pady 2
  439.     button .middle.page -text "PAGE"  \
  440.     -command "put_funct $token(K_CONTINUE)" -width 14 -padx 0 -pady 2
  441.     
  442.     pack .middle.pg  .middle.ps  .middle.bmenu .middle.ns  .middle.nread  \
  443.     .middle.ng .middle.page -side left -padx 8 -pady 2
  444. }
  445.  
  446. #
  447. #    Article menu
  448. #
  449.  
  450. proc menu_choose {scr x y} {
  451.     global ev_input EV_SELECT_E mdrag_id
  452.     global chp 
  453.     global cur_menu_pos
  454.  
  455.     if {$cur_menu_pos != 0} {
  456.     return
  457.     }
  458.  
  459.     scan [$scr index @99999,$y] %d.%d yc xc 
  460.  
  461. #        puts "ch  $x $y - $xc $yc - $chp"
  462.     set resced 1
  463.     
  464.     if {$y >= [winfo height $scr]} {
  465.     $scr yview scroll 2 units
  466.     } elseif {$y < 0} {
  467.     $scr yview scroll -2 units
  468.     } else {
  469.     set resced 0
  470.     }
  471.  
  472.     if {$yc != $chp } {
  473.     ev_type_menu 
  474.     if {$yc > $chp} {
  475.         set n 1 
  476.     } else {
  477.         set n -1
  478.     }
  479.     set ychk [expr $yc+$n]
  480.     for {set i [expr $chp+$n]} {$i != $ychk} {incr i $n} {
  481.         scan [$scr index $i.99999] %d.%d tyc txc
  482.         if {$txc > 0} {
  483.         rec_c $EV_SELECT_E $i
  484.         }
  485.     }
  486.     set chp $yc
  487.     }
  488.     after cancel $mdrag_id
  489.     if {$resced} {
  490.     set mdrag_id [after 100 "menu_choose $scr 1 $y"]
  491.     }    
  492. }
  493.  
  494. proc menu_choose-s {scr x y funct} {
  495.     global ev_input ev_type 
  496.     global chp cur_menu_pos
  497.  
  498.     set cur_menu_pos [lindex [$scr yview] 0]
  499.  
  500.     set p [$scr index @9999,$y]
  501.     scan $p %d.%d yc xc
  502.     if {$xc == 0} {
  503.     return
  504.     }
  505. #        puts  "ch-s $x $y - $xc $yc - $chp"
  506.     ev_type_menu
  507.     rec_c $funct $yc
  508.     set chp $yc
  509. }
  510.  
  511. proc menu_nextgroup {group} {
  512.     global m_newgroup
  513.  
  514.     more_clear
  515.     thread_clear
  516.     wm iconname . $group
  517.     wm title . nn:$group
  518.     set m_newgroup 2
  519. }
  520.  
  521.   
  522. proc menu_min {} {
  523.     global Config m_newgroup group_menu_length
  524.     global cur_menu_pos
  525.  
  526.     if {$Config(menu_max) == $Config(menu_min)} {
  527.     return
  528.     }
  529.  
  530.     if {$m_newgroup == 1} {
  531.     if {$group_menu_length < $Config(menu_min)} {
  532.         set mmin $group_menu_length
  533.     } else {
  534.         set mmin $Config(menu_min)
  535.     }
  536.     menu_resize $mmin
  537.     set m_newgroup 0
  538.     }
  539. }
  540.  
  541. proc menu_max {l} {
  542.     global Config group_menu_length m_newgroup
  543.  
  544.     if {$Config(menu_max) == $Config(menu_min)} {
  545.     return
  546.     }
  547.  
  548.     if {$m_newgroup == 2} {
  549.     set ht [lindex [.menu.article configure -height] 4]
  550.     if {$ht > $l} {
  551.         set l $ht
  552.     }
  553.  
  554.     if {$group_menu_length < $Config(menu_max)} {
  555.         set mmax $group_menu_length
  556.     } else {
  557.         set mmax $Config(menu_max)
  558.     }
  559.  
  560.     if {$l < $mmax} {
  561.         menu_resize $l
  562.     } else {
  563.         menu_resize $mmax
  564.     }
  565.     }
  566.     set m_newgroup 1
  567. }
  568.  
  569. proc menu_resize {l} {
  570.     global Config menu_extended
  571.  
  572.     .menu.article configure -height $l
  573.     .menu.index configure -height $l
  574.  
  575.     if {$menu_extended > 0} {
  576.     set n [expr $menu_extended +1]
  577.     .menu.article delete "end - $n chars" end
  578.     set menu_extended 0
  579.     }
  580.     m_scrollbar .menu.article .menu.sx $Config(horizontal_scrollbars)
  581. }
  582.  
  583. proc m_scrollbar {w s conf} {
  584.  
  585.     scan [$w xview] "%f %f" stx fnx
  586.     set xv [expr $fnx - $stx]
  587.     if {[winfo ismapped $s]} {
  588.     if {((($xv == 1.0) && ($conf != 2)) || ($conf == 0))} {
  589.         pack forget $s
  590.     } 
  591.     } else {
  592.     if {((($xv < 1.0) && ($conf != 0)) || ($conf == 2))} {
  593.         pack $s -side bottom -fill x 
  594.     }        
  595.     }
  596. }   
  597.  
  598. proc menu_clear {} {
  599.     global menu_extended
  600.  
  601.     .menu.article delete 0.0 end
  602.     set menu_extended 0
  603. }
  604.  
  605. proc menu_clear_partial {l} {
  606.     global menu_extended
  607.  
  608.     .menu.article delete $l.0 end
  609.     set menu_extended 0
  610. }
  611.  
  612. proc menu_pos {y} {
  613.     global cur_menu_pos
  614.  
  615.     set t [.menu.sy get]
  616.     scan $t "%f %f" first last
  617.  
  618.     set lines [.menu.article index end]
  619.     set yl [expr $lines*$last]
  620.     set yf [expr $lines*$first]
  621. #            puts "lines=$lines first=$first last=$last yl=$yl yf=$yf y=$y cp=$cur_menu_pos"
  622.     if {$cur_menu_pos == 0} {
  623.     if {($y > $yl) || \
  624.         ($y < $yf)} {
  625.         .menu.article yview [expr $y-2]
  626.     }
  627.     } else {
  628.     .menu.article yview moveto $cur_menu_pos
  629.     set cur_menu_pos 0
  630.     }
  631. }
  632.  
  633. proc menu_mark {y} {
  634.     .menu.article tag remove mark 0.0 end
  635.     .menu.article tag remove select $y.0 [expr $y+1].0
  636.     .menu.article tag add mark $y.0 [expr $y+1].0
  637.     menu_pos $y
  638. }
  639.  
  640. proc menu_inverse {y} {
  641.     .menu.article tag add select $y.0 [expr $y+1].0
  642. }
  643.  
  644. proc menu_under {y} {
  645.     .menu.article tag add under $y.0 [expr $y+1].0
  646. }
  647.  
  648. proc menu_p_inverse {y xs xf} {
  649.     .menu.article tag add select $y.0 [expr $y+1].0
  650. }
  651.  
  652. proc menu_normal {y} {
  653.     .menu.article tag remove select $y.0 [expr $y+1].0
  654.     .menu.article tag remove under $y.0 [expr $y+1].0
  655. }
  656.  
  657. proc menu_ent { yp xp} {
  658.     global menu_ent_t 
  659.     set end [.menu.article index end]
  660.  
  661.     scan $end %d.%d yl dd
  662.     incr yl -1
  663.     if {$yp > $yl} {
  664.     .menu.article insert $end "\n"
  665.     }
  666.     .menu.article delete $yp.0 "$yp.0 lineend"
  667.     .menu.article insert $yp.0 $menu_ent_t
  668.     .menu.article tag remove fix $yp.0 "$yp.0 lineend"
  669.     .menu.article tag add fix $yp.0 $yp.$xp
  670.     .menu.article tag add indx $yp.0 $yp.1
  671. }
  672.  
  673. proc menu_fill { yp xp} {
  674.     global menu_ent_t 
  675.  
  676.     .menu.article insert end $menu_ent_t
  677.     .menu.article tag add fix $yp.0 $yp.$xp
  678.     .menu.article tag add indx $yp.0 $yp.1
  679. }
  680.  
  681. proc set_read_mode {{c " "}} {
  682.     global read_mode
  683.     set read_mode $c
  684. }
  685.  
  686. # changes the state of buttons dependent on menu or article modes
  687. proc set_menu_mode {c} {
  688.     global menu_mode has_exmh
  689.  
  690.     set menu_mode $c
  691.     if {$menu_mode == "m"} {
  692.     button_mode .middle.bmenu disabled
  693.     button_mode .bottom.bns disabled
  694.     button_mode .bottom.bp disabled
  695.     button_mode .bottom.next disabled
  696.     button_mode .bottom.lv disabled
  697.     .middle.nread configure -text "read/skip"
  698.     .top.a.art  entryconfigure 8 -state disabled
  699.     .top.a.art.a entryconfigure 1 -state disabled
  700.     .top.a.art.a entryconfigure 2 -state disabled
  701.     .top.a.art.a entryconfigure 3 -state disabled
  702.     .top.o.others entryconfigure 2 -state   normal
  703.     .top.o.others entryconfigure 3 -state  normal
  704.     } else {
  705.     button_mode .middle.bmenu normal
  706.     button_mode .bottom.bns normal
  707.     button_mode .bottom.bp normal
  708.     button_mode .bottom.next normal
  709.     button_mode .bottom.lv normal
  710.     .middle.nread configure -text "skip G"
  711.     .top.a.art entryconfigure 8 -state  normal
  712.     if {$has_exmh} {
  713.         .top.a.art.a entryconfigure 1 -state normal
  714.         .top.a.art.a entryconfigure 2 -state normal
  715.         .top.a.art.a entryconfigure 3 -state normal
  716.     }
  717.     .top.o.others entryconfigure 2 -state  disabled
  718.     .top.o.others entryconfigure 3 -state  disabled
  719.     }
  720. }
  721.  
  722. proc menu_Make {} {
  723.     global color_bd color_bs color_w monochrome EV_SELECT EV_SELECT_C EV_SELECT_E EV_SELECT_C_E
  724.     global menu_extended mdrag_id
  725.     set menu_extended 0
  726.     set mdrag_id 0
  727.  
  728.     frame .menu
  729.  
  730.     text .menu.article -relief raised -bd 2 \
  731.     -cursor left_ptr -width 80\
  732.     -wrap none -yscrollcommand ".menu.sy set" -xscrollcommand ".menu.sx set"
  733.  
  734.     bind .menu.article <B1-Motion> "menu_choose .menu.article %x %y; break"
  735.     bind .menu.article <Button-1> "menu_choose-s .menu.article %x %y $EV_SELECT_E; break"
  736.     bind .menu.article <B1-Leave> "break"
  737.     bind .menu.article <B1-Enter> "break"
  738.     bind .menu.article <ButtonRelease-1> {after cancel $mdrag_id}
  739.     bind .menu.article <ButtonRelease-2> "break"
  740.     bind .menu.article <Button-3> "menu_choose-s .menu.article %x %y $EV_SELECT_C_E; break"
  741.     bindtags .menu.article {.menu.article Text . all}
  742.     
  743.     text_bindings .menu.article 
  744.  
  745.     .menu.article tag configure fix \
  746.     -font [option get .menu.article fixed_font {} ]
  747.  
  748.     .menu.article tag configure indx \
  749.     -borderwidth 2 -background \
  750.     $color_bd -font [option get .menu.article label_font {} ] 
  751.     if {$monochrome == 1} {
  752.     .menu.article tag configure select -background black -foreground white 
  753.     .menu.article tag configure mark -bgstipple gray25 -background black
  754.     } else {
  755.     .menu.article tag configure select -background  $color_bs -relief raised -borderwidth 1
  756.     .menu.article tag configure mark -background  $color_bd -relief raised -borderwidth 1
  757.     }
  758.     .menu.article tag configure under -underline 1
  759.     scrollbar .menu.sy  -command ".menu.article yview"
  760.     scrollbar .menu.sx  -command ".menu.article xview"  -orient horiz 
  761.     
  762.     text .menu.index -relief raised -bd 2 -width 1 -background \
  763.     $color_bd -font [option get .menu.article prompt_font {} ]
  764.     .menu.index insert end "a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\nx\ny\nz\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9"
  765.     pack .menu.index -side left -anchor n
  766.  
  767.     text .menu-g -relief raised -bd 2  \
  768.     -height 1 \
  769.         -font [option get .menu.article prompt_font {} ]
  770.     .menu-g tag configure pcolor  -foreground  \
  771.     [option get .menu-g prompt_color {}]
  772.  
  773.     text .menu-pr -relief raised -bd 2  \
  774.     -height 1 -wrap none\
  775.         -font [option get .menu.article prompt_font {} ]
  776.     bind .menu-pr <Button-1> break
  777.     bind .menu-pr <ButtonRelease-2> break
  778.     bind .menu-pr <2> prompt_insert
  779.     .menu-pr tag configure pcolor  -foreground  \
  780.     [option get .menu-pr prompt_color {}] -relief sunken
  781.  
  782.     .menu.article tag raise indx
  783.  
  784.     pack .menu.sy -side right -fill y
  785.     pack .menu.article -side top -fill x
  786. }
  787.  
  788. proc menu_handle_Make {w} {
  789.     global color_bd
  790.  
  791.     frame $w-handle -height 12 -width 12 -relief raised -borderwidth 2 \
  792.     -cursor double_arrow -background $color_bd
  793.     place $w-handle -relx 0.95 -y -6 -in $w
  794.  
  795.     bind $w-handle <Button-1> "menu_drag $w 0"
  796.     bind $w-handle <B1-Motion> "menu_drag $w %y"
  797.     bind $w-handle <ButtonRelease-1> "menu_drag_resize $w %y 1"
  798.     bind $w-handle <Button-2> "menu_drag $w 0"
  799.     bind $w-handle <B2-Motion> "menu_drag $w %y"
  800.     bind $w-handle <ButtonRelease-2> "menu_drag_resize $w %y 2"
  801.     frame $w-bar -width 800 -height 3 -bg red
  802. }
  803.  
  804. proc menu_drag {w y} {
  805.     place $w-bar -y [top_y  .menu-pr $y] -x [top_x  .menu-pr 0] -anchor w
  806. }
  807.     
  808. proc menu_drag_resize {w y b} {
  809.     global menu_mode Config
  810.  
  811.     set curr [top_y  .menu-pr $y]
  812.     set menu_top [top_y .menu.article 0]
  813.     set menu_height [winfo height .menu.article]
  814.     set menu_chars [lindex [.menu.article configure -height] 4]
  815.     set new_size [expr (($curr-$menu_top)*$menu_chars)/$menu_height]
  816.  
  817.     .menu.article configure -height $new_size
  818.     .menu.index configure -height $new_size
  819.     if {$b == 2} {
  820.     if {$menu_mode == "m"} {
  821.         msg_tmp "Setting menu_max"
  822.         set Config(menu_max) $new_size
  823.     } else {
  824.         msg_tmp "Setting menu_min"
  825.         set Config(menu_min) $new_size
  826.     }
  827.     }
  828.     place  forget $w-bar
  829. }
  830.  
  831. proc menu_where {} {
  832.      set t [.menu.sy get]
  833.     scan $t "%f %f" first last
  834.     set lines [.menu.article index end]
  835.     set page [expr $first*$lines] 
  836.     return $page
  837. }
  838.  
  839. proc menu_chop {} {
  840. #note display problem with last line
  841.     if {[.menu.article get  "end - 1 chars"] == "\n"} {
  842.     .menu.article delete "end - 1 chars"
  843.     }
  844. }
  845.  
  846. #               return 1 if not at the begining/end in menu display
  847. proc menu_page {dir unit} {
  848.     global menu_extended
  849.  
  850.     set t [.menu.sy get]
  851.     #      compensate for the fact that the bottom line
  852.     #      nolonger scrolls past the bottom of the window
  853.     scan $t "%f %f" first last
  854.     set fraction [expr $last-$first]
  855.     set lines [.menu.article index end]
  856.     set page [expr $fraction*$lines]
  857.     set remain [expr (1-$last)*$lines]
  858. #        puts "lines=$lines page=$page remain=$remain t=$t"
  859.     if {"$dir" == "+" && !$menu_extended && ($page > $remain) && ($fraction != 1.0)} {
  860.     set pad [expr int($page-$remain)]
  861.     .menu.article insert end [string range "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" 1 $pad]
  862.     set menu_extended $pad
  863.     }
  864.     if {("$dir" == "-" && $first<=0.0) || ("$dir" == "+" && $last>=1.0)} {
  865.     return 0
  866.     }
  867.     set sign [expr ("$dir"=="+"?"":"-")]
  868.     switch -- $unit {
  869.     line    {.menu.article yview scroll ${sign}1 units}
  870.     half    {.menu.article yview scroll ${sign}[expr int($page/2+1)] units}
  871.     page    {.menu.article yview scroll ${sign}1 pages
  872.              .menu.article yview scroll ${sign}2 units}
  873.     all    {if {"$dir" == "+"} {
  874.             .menu.article yview moveto [expr 1.0-($last-$first)]
  875.          } else {
  876.             .menu.article yview moveto 0.0
  877.          }
  878.         }
  879.     }
  880.     return 1
  881. }
  882.  
  883. proc info_reset {} {
  884.     global pr_pt
  885.  
  886.     set pr_pt 0
  887. }
  888.  
  889. proc info_msg {txt { level normal }} {
  890.     global pr_pt
  891.  
  892. #    puts "$level $pr_pt $txt"
  893.     if {$pr_pt == 0} {
  894.     .menu-pr insert end  "     "
  895.     set pr_pt [.menu-pr index "end - 1 chars"]
  896.     }
  897.  
  898.     .menu-pr delete $pr_pt end
  899.     .menu-pr insert end "$txt" pcolor 
  900.     update idletasks
  901. }
  902.  
  903. proc mprompt_msg {txt} {
  904.     global Config g_pt
  905.  
  906.     if {$g_pt == 0} {
  907.     .menu-g insert end  "     "
  908.     set g_pt [.menu-g index "end - 1 chars"]
  909.     } else {
  910.     .menu-g delete $g_pt end
  911.     }
  912.     
  913.     .menu-g insert end "$txt" pcolor 
  914. }
  915.     
  916. proc mprompt_clear {} {
  917.     global Config g_pt
  918.  
  919.     if {$g_pt != 0} {
  920.       .menu-g delete $g_pt end
  921.     }
  922. }
  923.  
  924. proc pprompt_msg {txt } {
  925.     global Config pr_pt
  926.  
  927.     if {$Config(compressed_prompt) == 0} return
  928.  
  929.     if {$pr_pt == 0} {
  930.     .menu-pr insert end  "     "
  931.     set pr_pt [.menu-pr index "end - 1 chars"]
  932.     }
  933.     .menu-pr insert end "$txt" pcolor 
  934. }
  935.  
  936. proc pprompt_delc {} {
  937.     global Config pr_pt
  938.  
  939.     if {$Config(compressed_prompt) == 0} return
  940.  
  941.     if {$pr_pt != 0} {
  942.     .menu-pr delete "end -2 chars"
  943.     }
  944. }
  945.  
  946. proc pprompt_clear {} {
  947.     global Config pr_pt
  948.  
  949.     if {$Config(compressed_prompt) == 0} return
  950.  
  951.     if {$pr_pt != 0} {
  952.     .menu-pr delete $pr_pt end
  953.     }
  954. }
  955.  
  956. proc pprompt_clrline {pos} {
  957.     global Config pr_pt
  958.  
  959.     if {$Config(compressed_prompt) == 0} return
  960.  
  961.     if {$pr_pt != 0} {
  962.     scan $pr_pt 1.%d base
  963.     .menu-pr delete "$pos +$base chars" end
  964.     }
  965. }
  966.  
  967. #
  968. #    Article display
  969. #
  970. proc more_all {state} {
  971.     if {$state == "normal"} {
  972.     pack .bottom.all -after .bottom.page -side left -padx 5
  973.     } else {
  974.     pack forget .bottom.all
  975.     }
  976. }
  977.  
  978. proc more_bar {} {
  979.     global Config
  980.  
  981.     m_scrollbar .more.t .more.sx $Config(horizontal_scrollbars)
  982. }
  983.  
  984. proc more_uri {} {
  985.     global Config
  986.  
  987.     if {$Config(scan_uri)} {
  988.     do_uri
  989.     }
  990. }
  991.  
  992. proc more_font {} {
  993.     global TConfig
  994.  
  995.     #    packer strangeness
  996.     scan [.menu.article configure -height] "-height height Height %d %d" x ht
  997.  
  998.     if {$TConfig(mono_font)} {
  999.     .more.t configure -font [option get .more fix_font {} ]
  1000.     } else {
  1001.     .more.t configure -font [option get .more  var_font {} ]
  1002.     }
  1003.     more_bar
  1004. }
  1005.  
  1006. proc more_b {} {
  1007.     global more_l_t
  1008.     .more.t insert end $more_l_t
  1009.     .more.t tag add bold "end linestart" "end -2 chars"
  1010. }
  1011.  
  1012. proc more_l {} {
  1013.     global more_l_t
  1014.     .more.t insert end $more_l_t
  1015. }
  1016.  
  1017. proc more_clear {} {
  1018.     global more_pos str_old more_extended more_color
  1019.  
  1020.     if {[lindex [.more.t configure -state] 4] == "disabled"} {
  1021.     clear_mime
  1022.     }
  1023.     .more.t configure -background $more_color
  1024.  
  1025.     set more_pos 1
  1026.     .more.t delete 0.0 end
  1027.     set str_old ""
  1028.     set more_extended 0
  1029. }
  1030.  
  1031. #               return 1 if not at the begining/end in article display
  1032. proc page {dir unit} {
  1033.     global more_extended
  1034.  
  1035.     set t [.more.sv get]
  1036.     #      compensate for the fact that the bottom line
  1037.     #      nolonger scrolls past the bottom of the window
  1038.     scan $t "%f %f" first last
  1039.     set lines [.more.t index end]
  1040.     set page [expr ($last-$first)*$lines]
  1041.     set remain [expr (1-$last)*$lines+2]
  1042.     #    puts "lines=$lines page=$page remain=$remain"
  1043.     if {"$dir" == "+" && !$more_extended && ($page > $remain)} {
  1044.     set pad [expr int($page-$remain)]
  1045.     #        puts "pad=$pad"
  1046.     .more.t insert end [string range "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" 1 $pad]
  1047.     set more_extended $pad
  1048.     }
  1049.     if {("$dir" == "-" && $first<=0.0) || ("$dir" == "+" && $last>=1.0)} {
  1050.     return 0
  1051.     }
  1052.     set sign [expr ("$dir"=="+"?"":"-")]
  1053.     switch -- $unit {
  1054.     line    {.more.t yview scroll ${sign}1 units}
  1055.     half    {.more.t yview scroll ${sign}[expr int($page/2+1)] units}
  1056.     page    {.more.t yview scroll ${sign}1 pages}
  1057.     all    {if {"$dir" == "+"} {
  1058.             .more.t yview moveto [expr 1.0-($last-$first)]
  1059.          } else {
  1060.             .more.t yview moveto 0.0
  1061.          }
  1062.         }
  1063.     }
  1064.     return 1
  1065. }
  1066.  
  1067. #              Next article or group
  1068. proc do_next {} {
  1069.     global token
  1070.     put_funct $token(K_NEXT_ARTICLE)
  1071. }
  1072.  
  1073. #              Prev article or group
  1074. proc do_prev {} {
  1075.     global token
  1076.     put_funct $token(K_BACK_ARTICLE)
  1077. }
  1078.  
  1079. proc more-search {} {
  1080.     global more_pos str_old 
  1081.     set t [.more.sv get]
  1082.     scan $t "%f %f" f l
  1083.     set lines [.more.t index end]
  1084.     set first [expr round($f*$lines)]
  1085.     set last [expr round($l*$lines)]
  1086.     set win [expr round(($l-$f)*$lines)]
  1087.  
  1088.     set str [.bottom.search.txt get]
  1089.     if {$str == ""} {
  1090.     return
  1091.     }
  1092.  
  1093.     if {$str_old != $str} {
  1094.     .more.t tag remove inv 0.0 end
  1095.     set str_old $str
  1096.     set more_pos $first
  1097.     }
  1098.  
  1099.     if {$more_pos < $first || $more_pos > [expr $last+1]} {
  1100.     set more_pos  [expr $first]
  1101.     }
  1102.  
  1103.     .more.t tag configure inv -underline 1
  1104.     scan [.more.t index end] %d nl
  1105.     set ln [string length $str]
  1106.     set str [string tolower $str]
  1107.  
  1108.     set first_match 1
  1109.     set bound $nl
  1110.     set found 0
  1111.     for {set i $more_pos} {$i <= $nl} {incr i} {
  1112.     set line [string tolower [.more.t get $i.0 $i.1000]]
  1113.  
  1114.     if {[set n [string first $str $line]] != -1} {
  1115.         set offset 0
  1116.         set found 1
  1117.  
  1118.         while {$n >= 0} {
  1119.             .more.t tag add inv $i.[expr $n+$offset] $i.[expr $n+$ln+$offset]
  1120.         set offset [expr $n+$ln+$offset]
  1121.         set n [string first $str [string range $line $offset 1000]]
  1122.             if {$first_match} {
  1123.             .more.t yview  [expr $i-4]
  1124.             set bound [expr $i+$win-4]
  1125.             set first_match 0
  1126.             }
  1127.         }
  1128.     }
  1129.         if {$i >= $bound} {
  1130.         set more_pos  $i
  1131.         break
  1132.         }
  1133.     }
  1134.     if {!$found} {
  1135.     msg_tmp "String not found"
  1136.     }
  1137. }
  1138.  
  1139. proc more-search-b {} {
  1140.     global more_pos str_old 
  1141.     set t [.more.sv get]
  1142.  
  1143.     scan $t "%f %f" f l
  1144.     set lines [.more.t index end]
  1145.     set first [expr round($f*$lines)]
  1146.     set last [expr round($l*$lines)]
  1147.     set win [expr round(($l-$f)*$lines)]
  1148.  
  1149.     set str [.bottom.search.txt get]
  1150.     if {$str == ""} {
  1151.     return
  1152.     }
  1153.  
  1154.     if {$str_old != $str} {
  1155.     .more.t tag remove inv 0.0 end
  1156.     set str_old $str
  1157.         set more_pos $last
  1158.     }
  1159.     if {[expr $more_pos-1] < $first || $more_pos > $last} {
  1160.         set more_pos  [expr $first]
  1161.     }
  1162.  
  1163.     .more.t tag configure inv -underline 1
  1164.     scan [.more.t index end] %d nl
  1165.     set ln [string length $str]
  1166.     set str [string tolower $str]
  1167.  
  1168.     set first_match 1
  1169.     set bound 0
  1170.     set found 0
  1171.     for {set i $more_pos} {$i > 0} {set i [expr $i-1]} {
  1172.     set line [string tolower [.more.t get $i.0 $i.1000]]
  1173.  
  1174.     if {[set n [string first $str $line]] != -1} {
  1175.         set offset 0
  1176.         set found 1
  1177.         while {$n >= 0} {
  1178.             .more.t tag add inv $i.[expr $n+$offset] $i.[expr $n+$ln+$offset]
  1179.             set offset [expr $n+$ln+$offset]
  1180.             set n [string first $str [string range $line $offset 1000]]
  1181.                 if {$first_match} {
  1182.                     .more.t yview  [expr $i-$win+3]
  1183.                     set bound [expr $i-$win+3]
  1184.                     set first_match 0
  1185.                 }
  1186.         }
  1187.     }
  1188.         if {$i <= $bound} {
  1189.         set more_pos $i
  1190.         break
  1191.         }
  1192.     }
  1193.     if {!$found} {
  1194.     msg_tmp "String not found"
  1195.     }
  1196. }
  1197.  
  1198. proc more-srch {} {
  1199.     global nn_x_dir
  1200.  
  1201.     frame .bottom.search
  1202.  
  1203.     image create bitmap down -file $nn_x_dir/tcl/down.xbm
  1204.     image create bitmap up -file $nn_x_dir/tcl/up.xbm
  1205.  
  1206.     button .bottom.search.bt -image down  -command "more-search" -bd 2 \
  1207.     -relief raised  -padx 0 -pady 2
  1208.     button .bottom.search.bf -image up -command "more-search-b" -bd 2 \
  1209.     -relief raised -padx 0 -pady 2
  1210.     entry .bottom.search.txt -relief sunken -width 15
  1211.     pack .bottom.search.bt .bottom.search.txt  .bottom.search.bf -side left
  1212.     bind .bottom.search.txt <Return> "more-search"
  1213. }
  1214.  
  1215. proc toggle_prefetcher {} {
  1216.     global TConfig
  1217.     
  1218.     nn_set_var prefetch $TConfig(prefetch_on)
  1219.     if {$TConfig(prefetch_on) == "0"} {
  1220.     kill_prefetcher
  1221.     abort_prefetcher
  1222.     }
  1223. }
  1224.  
  1225. proc bottom_buttons {} {
  1226.     global token TConfig
  1227.     
  1228.     frame .bottom 
  1229.     frame .bottom.b -borderwidth 2  -relief ridge
  1230.  
  1231.     menubutton .bottom.o -text "Opts" -menu .bottom.o.m -bd 1 \
  1232.     -relief raised  -pady 3 -indicatoron 1
  1233.     menu .bottom.o.m
  1234.     .bottom.o.m add checkbutton -variable TConfig(mono_font) -label "Mono font" \
  1235.     -command "more_font"  -selectcolor red3
  1236.     .bottom.o.m add checkbutton -variable TConfig(balloon_on) -label "Balloon help" \
  1237.     -selectcolor red3
  1238.     .bottom.o.m add checkbutton -variable TConfig(prefetch_on) -label "Prefetch articles" \
  1239.     -selectcolor red3 -command toggle_prefetcher -onvalue "on" -offvalue "off"
  1240.  
  1241.     button .bottom.lv -text "leave"  -command "put_extended {leave-next}" \
  1242.     -width 7 -padx 0 -pady 2
  1243.     button .bottom.bns -text "n-subj"  \
  1244.     -command "put_funct $token(K_NEXT_SUBJECT)" \
  1245.     -width 7 -padx 0 -pady 2
  1246.     button .bottom.all -text "All"  \
  1247.     -command "do_more_lines" -width 5 -padx 0 -pady 2
  1248.     button .bottom.bp -text "prev"  -command "do_prev" -width 7 -padx 0 -pady 2
  1249.     button .bottom.next -text "next"  -command "do_next" -width 7 -padx 0 -pady 2
  1250.     button .bottom.page -text "PAGE"  -command "put_funct $token(K_CONTINUE)" \
  1251.     -width 10 -padx 0 -pady 2
  1252.     more-srch
  1253.     
  1254.     pack .bottom.search -side left -padx 5 -in .bottom.b
  1255.     pack .bottom.lv .bottom.bns   .bottom.bp .bottom.next \
  1256.     .bottom.page -side left -padx 3 -pady 2 -in .bottom.b
  1257.  
  1258.     pack .bottom.o -side left -padx 5 -in .bottom
  1259.     pack .bottom.b -side left
  1260. }
  1261.  
  1262. proc do_more_lines {} {
  1263.     global token
  1264.     more_lines 100000
  1265.     put_funct $token(K_REDRAW)
  1266. }
  1267.  
  1268. proc more_ff {} {
  1269.     .more.t insert end "\n\n"
  1270.     .more.t tag add ff  "end - 2 chars" "end - 1 chars"
  1271. }
  1272.  
  1273. proc more_Make {} {
  1274.     global color_w Config TConfig has_exmh more_color
  1275.  
  1276.     frame .more
  1277.  
  1278.     if {$TConfig(mono_font)} {
  1279.     set font [option get .more fix_font {} ]    
  1280.     } else {
  1281.     set font [option get .more var_font {} ]    
  1282.     }
  1283.  
  1284.     if {$has_exmh} {
  1285.     Widget_Text .more 1 -relief raised -bd 2  \
  1286.         -font $font -wrap none -xscrollcommand ".more.sx set"
  1287.     } else {
  1288.     frame .more.f
  1289.         text .more.t -relief raised -bd 2 -yscrollcommand ".more.sv set" \
  1290.         -height 1 -wrap none -cursor left_ptr -xscrollcommand ".more.sx set"\
  1291.         -font $font -width 1
  1292. #        -setgrid true
  1293.     pack  .more.t -side left -expand yes -fill both -in .more.f
  1294.     scrollbar .more.sv  -command ".more.t yview"
  1295.     
  1296.     pack .more.sv -side left -fill y -in .more.f
  1297.     pack .more.f -side top -expand yes -fill both
  1298.     }
  1299.     set more_color [.more.t cget -background]
  1300.     
  1301.     scrollbar .more.sx  -command ".more.t  xview"  -orient horiz 
  1302.     more_bar
  1303.  
  1304.     text_bindings .more.t
  1305.     bind .more.t <ButtonRelease-2> "break"
  1306.  
  1307.     more_tags
  1308.  
  1309. }
  1310.  
  1311. proc more_tags {} {
  1312.     global color_bd
  1313.     .more.t tag configure bold -font [option get .more bold_font {} ]
  1314.     .more.t tag configure ff  -relief raised -borderwidth 2 -background\
  1315.     $color_bd
  1316. }
  1317. proc main_Make {} {
  1318.     global Config nn_x_dir
  1319.  
  1320.  
  1321.     top_buttons
  1322.     pack  .top -side top -fill x
  1323.     balloonHelp_traverse .top
  1324.  
  1325.     menu_Make
  1326.     pack .menu-g .menu  -side top -fill x
  1327.     pack .menu-pr -side top -fill x 
  1328.     balloonHelp_traverse .menu
  1329.  
  1330.     middle_buttons
  1331.     more_Make
  1332.     pack  .more -side top -expand yes -fill both
  1333.  
  1334.     bottom_buttons
  1335.     pack  .bottom -side top  -fill x -padx 8
  1336.     balloonHelp_traverse .bottom
  1337.  
  1338.     if {$Config(middle_button_pos) == 2} {
  1339.     pack  .middle -side top -after .top
  1340.     } elseif {$Config(middle_button_pos) == 1} {
  1341.     pack  .middle -side top -after .menu-pr
  1342.     } else {
  1343.     pack  .middle -side top -after .more
  1344.     }
  1345.     balloonHelp_traverse .middle
  1346.  
  1347.     if {($Config(separate_prompt) == 0) && ($Config(compressed_prompt) != 2)} {
  1348.     pack .prompt -side top -fill x
  1349.     }
  1350.     menu_handle_Make .menu-pr
  1351.     balloonHelp_traverse .menu-pr-handle
  1352. }
  1353.  
  1354.